//		Instru��es de instala��o em http://comofazerumsite.com/add-ons/banner-rotativo-javascript.html 

//								EDITAR A PARTIR DAQUI 
///////////////////////////////////////////////////////////////////////////////////

var settings = {
	
	'define_size':			0,         		// 	Se o valor for 1 entro todos os anuncios v�o ficar com as dimens�es 
											//  defindas nas 2 linhas seguintes
	'img_width':			468,			//	Forcar todos os anuncios a ter esta largura, s� funciona se o valor 
											//  definido antes for 1
	'img_height':			60, 			// 	Forcar todos os anuncios a ter esta altura, s� funciona se o valor 
											//  definido tiver sido 1
	'refresh_time':			5000,			//	Milisegundos entre anuncios (se por exemplo quer 16 segundos deve 
											//  colocar 16000) - usar 0 para inactivar 
	'refresh_max':			100,			//	Numero m�ximo de mudan�as de anuncio de cada vez que a p�gina � carregada
	'duplicate_anuncios':	4,				//	Manter 0 para garantir que o mesmo anuncio n�o vai ser mostrado na mesma 	 
	                                        //  p�gina. S� ter� efeito se o mostrar_banner(); for usado mais do que uma 
											//  vez. Certifique-se que tem anuncios suficientes para preencher todos os
											//   espa�os publicit�rios ou o browser pode bloquear ou dar erro.
	'location_prefix': 		'adLocation-',	//	O prefixo dos IDs dos <div> que envolve os anuncios - este div � 
											//  gerado de forma dinamica. Um numero vai ser adicionado no fim desta string. 
	'location_class':		'swb',			//  Uma classe para adicionar a todas as <div>s que envolvem os anuncios 
	'window': 				'_blank',		//	Forma de abrir os links, na mesma ou numa janela nova, _self = mesma,
											//  _blank = nova. Use _top se estiver numa frame!		
	'default_ad_loc':		'default'		//	O espa�o publicit�rio, 'Localizacao_Banner', por defeito. Este espa�o
											//  fica associado a todos os anuncios para os quais n�o seja definido uma
											//  'localizacao_banner' na lista de anuncios abaixo
}

 
//alert(jQuery("#tooltipMural").html());

var anuncios = [];

function initBanner(niverMes, niverDia, agendaMes,agendaDia){
	
	anuncios = [
	//new anuncio( a, 'http://comofazerumsite.com', 'http://img190.imageshack.us/img190/5520/cfusbanner468x60.jpg', '30/02/2023', 'LocalAnuncios1'),
	//new anuncio('BLOG - Como Fazer Um Site', 'http://comofazerumsite.com/blog', 'http://img217.imageshack.us/img217/9375/cfusbannerblog468x60.jpg', '11/02/2029', 'LocalAnuncios1'),
	//new anuncio('FORUM - Como Fazer Um Site', 'http://comofazerumsite.com/forum', 'http://img13.imageshack.us/img13/594/cfusbannerforum468x60.jpg', '14/04/2022', 'LocalAnuncios1')
	new anuncio(niverMes, 'niverMes', '"muralTituloNiverMes"', '30/02/2023', 'LocalAnuncios1'),
	new anuncio(niverDia, 'niverDia', '"muralTituloNiverDia"', '11/02/2029', 'LocalAnuncios1'),
	new anuncio(agendaMes, 'agendaMes', '"muralTituloAgendaMes"', '14/04/2022', 'LocalAnuncios1'),
	new anuncio(agendaDia, 'agendaDia', '"muralTituloAgendaDia"', '14/04/2022', 'LocalAnuncios1')
]
}

//								N�o � preciso editar a partir daqui
///////////////////////////////////////////////////////////////////////////////////

var used = 0;
var location_counter = 0;
var refresh_counter = 1;
var map = new Array();
function anuncio(a, b, c, d, e) {
	this.name = a;
	this.url = b;
	this.image = c;
	this.date = d;
	if(a != '')
		this.active = 1;
	else
		this.active = 0;
	this.oid = 0;
	if (e != '') {
		this.loc = e
	} else {
		this.loc = settings.default_ad_loc
	}
}
function mostrar_banner(a,  niverMes, niverDia, agendaMes,agendaDia) {
	initBanner(niverMes, niverDia, agendaMes,agendaDia);
	location_counter = location_counter + 1;
	if (a != '' && a != undefined) {
		map[location_counter] = a
	} else {
		map[location_counter] = settings.default_ad_loc
	}
/*	var b = '\u003c\u0074\u0061\u0062\u006c\u0065\u003e\u003c\u0074\u0064\u003e\u003c\u0064\u0069\u0076\u0020\u0069\u0064\u003d\u0022'
			+ settings.location_prefix
			+ location_counter
			+ '" class="'
			+ settings.location_class
			+ '\u0022\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u006d\u0061\u0072\u0067\u0069\u006e\u003a\u0030\u0070\u0078\u003b\u0022\u003e\u003c\u002f\u0064\u0069\u0076\u003e\u003c\u002f\u0074\u0064\u003e\u003c\u002f\u0074\u0061\u0062\u006c\u0065\u003e';
*/	
	
	
	var b = "<table>" +
			"<td>" +
			"	<div " +
			"id=" 
			+'"adLocation-1"'
			+ " class="
			+ '"swb"'
			+ " style="
			+ '"margin-left:0px;"'
			+ "/>	</td>"+					
"		</table>";
	
	
	
	
	//document.write(b);
	 jQuery("#logo_fundo").html(b);
	//jQuery("#mural_ver_detalhes").html(link);
	display_anuncios(location_counter)
}
var r = '\u003c\u002f\u0061\u003e\u003c\u0062\u0072\u003e\u003c\u0063\u0065\u006e\u0074\u0065\u0072\u003e\u003c\u0064\u0069\u0076\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u006d\u0061\u0072\u0067\u0069\u006e\u003a\u0020\u0030\u0070\u0078\u003b\u0020\u0070\u0061\u0064\u0064\u0069\u006e\u0067\u003a\u0020\u0030\u0070\u0078\u003b\u0022\u003e\u003c\u0064\u0069\u0076\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0066\u006c\u006f\u0061\u0074\u003a\u0020\u006c\u0065\u0066\u0074\u003b\u0022\u003e\u003c\u0061\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0066\u006f\u006e\u0074\u003a\u0020\u006e\u006f\u0072\u006d\u0061\u006c\u0020\u0039\u0070\u0078\u0020\u0054\u0061\u0068\u006f\u006d\u0061\u002c\u0020\u0041\u0072\u0069\u0061\u006c\u002c\u0020\u0054\u0072\u0065\u0062\u0075\u0063\u0068\u0065\u0074\u002c\u0020\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061\u002c\u0020\u0046\u0072\u0065\u0065\u0053\u0061\u006e\u0073\u002c\u0020\u0073\u0061\u006e\u0073\u002d\u0073\u0065\u0072\u0069\u0066\u003b\u0066\u006f\u006e\u0074\u002d\u0073\u0069\u007a\u0065\u003a\u0020\u0038\u0070\u0078\u003b\u0074\u0065\u0078\u0074\u002d\u0064\u0065\u0063\u006f\u0072\u0061\u0074\u0069\u006f\u006e\u003a\u006e\u006f\u006e\u0065\u003b\u0022\u0020\u0068\u0072\u0065\u0066\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0063\u006f\u006d\u006f\u0066\u0061\u007a\u0065\u0072\u0075\u006d\u0073\u0069\u0074\u0065\u002e\u0063\u006f\u006d\u002f\u0061\u0064\u0064\u002d\u006f\u006e\u0073\u002f\u0062\u0061\u006e\u006e\u0065\u0072\u002d\u0072\u006f\u0074\u0061\u0074\u0069\u0076\u006f\u002d\u006a\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u002e\u0068\u0074\u006d\u006c\u0022\u003e\u0042\u0061\u006e\u006e\u0065\u0072\u0020\u0052\u006f\u0074\u0061\u0074\u0069\u0076\u006f\u003c\u002f\u0061\u003e\u003c\u002f\u0064\u0069\u0076\u003e\u003c\u0064\u0069\u0076\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0066\u006c\u006f\u0061\u0074\u003a\u0020\u0072\u0069\u0067\u0068\u0074\u003b\u0022\u003e\u003c\u0061\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0066\u006f\u006e\u0074\u003a\u0020\u006e\u006f\u0072\u006d\u0061\u006c\u0020\u0039\u0070\u0078\u0020\u0054\u0061\u0068\u006f\u006d\u0061\u002c\u0020\u0041\u0072\u0069\u0061\u006c\u002c\u0020\u0054\u0072\u0065\u0062\u0075\u0063\u0068\u0065\u0074\u002c\u0020\u0048\u0065\u006c\u0076\u0065\u0074\u0069\u0063\u0061\u002c\u0020\u0046\u0072\u0065\u0065\u0053\u0061\u006e\u0073\u002c\u0020\u0073\u0061\u006e\u0073\u002d\u0073\u0065\u0072\u0069\u0066\u003b\u0066\u006f\u006e\u0074\u002d\u0073\u0069\u007a\u0065\u003a\u0020\u0038\u0070\u0078\u003b\u0074\u0065\u0078\u0074\u002d\u0064\u0065\u0063\u006f\u0072\u0061\u0074\u0069\u006f\u006e\u003a\u006e\u006f\u006e\u0065\u003b\u0022\u0020\u0068\u0072\u0065\u0066\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0063\u006f\u006d\u006f\u0066\u0061\u007a\u0065\u0072\u0075\u006d\u0073\u0069\u0074\u0065\u002e\u0063\u006f\u006d\u0022\u003e\u0043\u006f\u006d\u006f\u0020\u0046\u0061\u007a\u0065\u0072\u0020\u0055\u006d\u0020\u0053\u0069\u0074\u0065\u003c\u002f\u0061\u003e\u003c\u002f\u0064\u0069\u0076\u003e\u003c\u0064\u0069\u0076\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0063\u006c\u0065\u0061\u0072\u003a\u0020\u0062\u006f\u0074\u0068\u003b\u0022\u003e\u003c\u002f\u0064\u0069\u0076\u003e\u003c\u002f\u0064\u0069\u0076\u003e\u003c\u002f\u0063\u0065\u006e\u0074\u0065\u0072\u003e';
function display_anuncios(a) {
	var b = new Array();
	if (a == '' || !a || a < 0) {
		return
	}
	var c = anuncios.length;
	if ((c == used) && settings.duplicate_anuncios == 0) {
		return
	}
	for (i = 0; i < (anuncios.length); i++) {
		anuncios[i].oid = i;
		if ((anuncios[i].loc == map[a]) && (anuncios[i].active == 1)) {
			b.push(anuncios[i])
		}
	}
	var d = Math.floor(Math.random() * b.length);
	var e = b[d];
	var f = (settings.define_size == 1) ? ' width="' + settings.img_width
			+ '" height="' + settings.img_height + '"' : '';
//	var g = // '\u003c\u0061\u0020\u0068\u0072\u0065\u0066\u003d\u0022'
		//	+ e.url
		//	+ '\u0022\u0020\u0074\u0069\u0074\u006c\u0065\u003d\u0022'
			//+ e.name
		//	+ '\u0022\u0020\u0074\u0061\u0072\u0067\u0065\u0074\u003d\u0022'
		//	+ settings.window
		//	+ '\u0022\u0020\u0072\u0065\u006c\u003d\u0022\u006e\u006f\u0066\u006f\u006c\u006c\u006f\u0077\u0022\u003e\u003c\u0069\u006d\u0067\u0020\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0073\u0072\u0063\u003d\u0022'
		//	+ e.image + '"' + f + '\u0020\u0061\u006c\u0074\u003d\u0022'
		//	+ e.name //+ '\u0022\u0020\u002f\u003e'// + r + ''
			//;
	
	var link = "<div style="+'"margin-top:0px; margin-left:310px"' +"> " +
	"<a"+ " id="+'"formMural:cmlVerTodos"' +
		 "style=" + '"width:70px"' +  "onclick=" + '"' + "verDetalhes('"+  e.url +"');" +'"' +
		 "onclick=" + '"'+ "A4J.AJAX.Submit("+"'formMural'" +",event,{'similarityGroupingId':'formMural:cmlVerTodos','parameters':{'ajaxSingle':'formMural:cmlVerTodos','formMural:cmlVerTodos':'formMural:cmlVerTodos'} } );return false;" +'"' +
		"name=" +'"formMural:cmlVerTodos"' +
		 "href=" +'"#"' + ">Ver todos...</a>" +
		 		"	</div> ";
	
	var g = "<div id="+e.image+"> </div>"+
	"<div class="+'"field-clear"' + "></div>" +
	"<div class=" +'"dadosCompromissos"'
	+ " style="
	+ '"margin-left:15px;height:150px;width:400px;display:block"' +
	">"+ e.name +"</div>" +
			"<div class="+'"field-clear"' + "></div> " + link ;
	//g = e.name;
	var h = new Date();
	var j = e.date;
	j = j.split('/', 3);
	var k = new Date();
	k.setFullYear(parseInt(j[2]), parseInt(j[1]) - 1, parseInt(j[0]));
	if ((h < k) && e.active == 1) {
		var l = document.getElementById(settings.location_prefix + a);
		if (l == null) {
			alert('banner rotator\nError: adLocation doesn\'t exist!')
		} else {
			l.innerHTML = g;
			if (settings.duplicate_anuncios == 0) {
				anuncios[e.oid].active = 0;
				used++
			}
			return
		}
	} else {
		display_anuncios(a)
	}
	return
}
function refresh_anuncios() {
	if ((refresh_counter == settings.refresh_max) || settings.refresh_time < 1) {
		clearInterval(banner_refresh)
	}
	used = 0;
	for (j = 0; j < (anuncios.length); j++) {
		anuncios[j].active = 1
	}
	for (j = 1; j < (location_counter + 1); j++) {
		display_anuncios(j)
	}
	refresh_counter++
}
var banner_refresh = window
		.setInterval(refresh_anuncios, settings.refresh_time);


function escolher_banner(pos) {
	if ((refresh_counter == settings.refresh_max) || settings.refresh_time < 1) {
		clearInterval(banner_refresh)
	}
	used = 0;
	for (j = 0; j < (anuncios.length); j++) {
		anuncios[j].active = 1
	}
	for (j = 1; j < (location_counter + 1); j++) {
		display_anuncios_selecionado(j,pos);		
	}
	refresh_counter++
}

function display_anuncios_selecionado(a,d) {
	var b = new Array();
	if (a == '' || !a || a < 0) {
		return
	}
	var c = anuncios.length;
	if ((c == used) && settings.duplicate_anuncios == 0) {
		return
	}
	for (i = 0; i < (anuncios.length); i++) {
		anuncios[i].oid = i;
		if ((anuncios[i].loc == map[a]) && (anuncios[i].active == 1)) {
			b.push(anuncios[i])
		}
	}
	//var d = Math.floor(Math.random() * b.length);
	var e = b[d];
	var f = (settings.define_size == 1) ? ' width="' + settings.img_width
			+ '" height="' + settings.img_height + '"' : '';
//	var g = // '\u003c\u0061\u0020\u0068\u0072\u0065\u0066\u003d\u0022'
		//	+ e.url
		//	+ '\u0022\u0020\u0074\u0069\u0074\u006c\u0065\u003d\u0022'
			//+ e.name
		//	+ '\u0022\u0020\u0074\u0061\u0072\u0067\u0065\u0074\u003d\u0022'
		//	+ settings.window
		//	+ '\u0022\u0020\u0072\u0065\u006c\u003d\u0022\u006e\u006f\u0066\u006f\u006c\u006c\u006f\u0077\u0022\u003e\u003c\u0069\u006d\u0067\u0020\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0073\u0072\u0063\u003d\u0022'
		//	+ e.image + '"' + f + '\u0020\u0061\u006c\u0074\u003d\u0022'
		//	+ e.name //+ '\u0022\u0020\u002f\u003e'// + r + ''
			//;
	//var g = e.name;
	var link = "<div style="+'"margin-top:0px; margin-left:310px"' +"> " +
	"<a"+ " id="+'"formMural:cmlVerTodos"' +
		 "style=" + '"width:70px"' +  "onclick=" + '"' + "verDetalhes('"+  e.url +"');" +'"' +
		 "onclick=" + '"'+ "A4J.AJAX.Submit("+"'formMural'" +",event,{'similarityGroupingId':'formMural:cmlVerTodos','parameters':{'ajaxSingle':'formMural:cmlVerTodos','formMural:cmlVerTodos':'formMural:cmlVerTodos'} } );return false;" +'"' +
		"name=" +'"formMural:cmlVerTodos"' +
		 "href=" +'"#"' + ">Ver todos...</a>" +
		 		"	</div> ";
	
	var g = "<div id="+e.image+"> </div>"+
	"<div  class="+'"field-clear"' + "></div>" +
	"<div  class=" +'"dadosCompromissos"'
	+ " style="
	+ '"margin-left:15px;height:150px;display:block"' +
	">"+ e.name +"</div>" +
			"<div class="+'"field-clear"' + "></div> " + link ;
	var h = new Date();
	var j = e.date;
	j = j.split('/', 3);
	var k = new Date();
	k.setFullYear(parseInt(j[2]), parseInt(j[1]) - 1, parseInt(j[0]));
	if ((h < k) && e.active == 1) {
		var l = document.getElementById(settings.location_prefix + a);
		if (l == null) {
			alert('banner rotator\nError: adLocation doesn\'t exist!')
		} else {
			l.innerHTML = g;
			if (settings.duplicate_anuncios == 0) {
				anuncios[e.oid].active = 0;
				used++
			}
			return
		}
	} else {
		display_anuncios(a)
	}
	return
}

